#include "StdAfx.h"

LocaleMgr* Singleton<LocaleMgr>::m_instance = 0;

LocaleMgr::LocaleMgr()
{
	char fLocale[255];
	sprintf_s<255>(fLocale, "Locale-%s.txt", sMpqHandler.GetLocale().c_str());
	std::ifstream istr(fLocale, std::ios::in);
	char buffer[255];
	while(istr.getline(buffer, 255))
	{
		char* pNum = strtok(buffer, ":");
		char* pText = strtok(0, "\0");
		if(atoi(pNum))
			m_locales[atoi(pNum)] = pText;
	}
}

std::string LocaleMgr::GetLocale(ui32 dwIndex, std::string szDefault)
{
	if(m_locales[dwIndex] != "")
		return m_locales[dwIndex];
	else
		return szDefault;
}